package no.ntnu.fp.su.util;

public class GaussianRandomWalk {
	private double min;
	private double val;
	private double max;
	private double stdev;
	private double mean;
	public GaussianRandomWalk(double start, double min, double max, double mean, double stdev) {
		this.val=start;
		this.min=min;
		this.max=max;
		this.mean=mean;
		this.stdev=stdev;
	}
	public double next() {
		val=saturate(min,max,val+NormalDistribution.sample(mean, stdev));
		return val;
	}
	private static double saturate(double min, double max, double val) {
		val=Math.min(max, val);
		val=Math.max(min, val);
		return val;
	}
}
